java import text file into arraylist

103

java import text file into arraylist -

List<String> list = Files.readAllLines(new File("input.txt").toPath(), Charset.defaultCharset() );

java import text file into arraylist -

Scanner s = new Scanner(new File("filepath"));
ArrayList<String> list = new ArrayList<String>();
while (s.hasNext()){
    list.add(s.next());
}
s.close();

Comments

Submit
0 Comments